package com.qf.six.ssm.service.ad.impl;

import com.qf.six.ssm.commen.exception.ServiceException;
import com.qf.six.ssm.commen.request.AdParam;
import com.qf.six.ssm.commen.request.AdRequestParam;
import com.qf.six.ssm.commen.vo.ResponseCode;
import com.qf.six.ssm.entity.AdManager;
import com.qf.six.ssm.mapper.ad.AdMapper;
import com.qf.six.ssm.service.ad.AdService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
/**
 * @author ZL
 */
@Service
public class AdServiceImpl implements AdService {
    @Resource
    AdMapper adMapper;
    @Override
    public List<AdManager> getList() {
        List<AdManager> list = adMapper.selectAll();
        if(list.size() > 0){
            return list;
        } else {
            throw new ServiceException(ResponseCode.ERROR);
        }
    }

    @Override
    public int addAd(AdParam param) {
        int insert = adMapper.insert(param);
        if(insert > 0){
            return insert;
        }else {
            throw new ServiceException(ResponseCode.ERROR);
        }
    }

    @Override
    public List<AdManager> selectList(AdRequestParam param) {
        List<AdManager> list = adMapper.selectAd(param);
        if(list.size() > 0){
            return list;
        } else {
            throw new ServiceException(ResponseCode.ERROR);
        }
    }
}
